﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SqlSugar;
using Monk.Site.Assistant;
using Monk.Site.Models;
using FluentValidation;
using Monk.Site.Areas.Backend.Models;
using FluentValidation.Results;

namespace Monk.Site.Areas.Backend.Controllers
{
    public class EntryController : Controller
    {
        [HttpGet]
        public ActionResult Index()
        {
            return View();
        }

        [HttpPost]
        public ActionResult Signup(SignupModel model)
        {
            SignupModelValidator validator = new SignupModelValidator();
            ValidationResult results = validator.Validate(model);
            if (!results.IsValid)
            {
                // 判断是否是Ajax请求，如果是说明客户端运行脚本，否则跳转到错误页面提示
                foreach (var failure in results.Errors)
                {
                    return Content("Property " + failure.PropertyName + " failed validation. Error was: " + failure.ErrorMessage);
                }
            }
            return Content("");
        }
    }
}